/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author edgar
 */
@Entity
@Table(name = "clientes")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Clientes.findAll", query = "SELECT c FROM Clientes c"),
    @NamedQuery(name = "Clientes.findByCodCliente", query = "SELECT c FROM Clientes c WHERE c.codCliente = :codCliente"),
    @NamedQuery(name = "Clientes.findByDescripcion", query = "SELECT c FROM Clientes c WHERE c.descripcion = :descripcion"),
    @NamedQuery(name = "Clientes.findByEmail", query = "SELECT c FROM Clientes c WHERE c.email = :email"),
    @NamedQuery(name = "Clientes.findByTelefono", query = "SELECT c FROM Clientes c WHERE c.telefono = :telefono"),
    @NamedQuery(name = "Clientes.findByLimiteCredito", query = "SELECT c FROM Clientes c WHERE c.limiteCredito = :limiteCredito"),
    @NamedQuery(name = "Clientes.findBySaldoActual", query = "SELECT c FROM Clientes c WHERE c.saldoActual = :saldoActual")})
public class Clientes implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "cod_cliente")
    private Integer codCliente;
    @Size(max = 50)
    @Column(name = "descripcion")
    private String descripcion;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Size(max = 30)
    @Column(name = "email")
    private String email;
    @Size(max = 30)
    @Column(name = "telefono")
    private String telefono;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "limite_credito")
    private Float limiteCredito;
    @Column(name = "saldo_actual")
    private Integer saldoActual;
    @OneToMany(mappedBy = "codCliente")
    private List<VentasCabecera> ventasCabeceraList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "clientes")
    private List<OrdenesCabecera> ordenesCabeceraList;
    @OneToMany(mappedBy = "codCliente")
    private List<Pagos> pagosList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "clientes")
    private List<PagosDetalle> pagosDetalleList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "clientes")
    private List<OrdenesDetalle> ordenesDetalleList;
    @OneToMany(mappedBy = "codCliente")
    private List<PagosCabecera> pagosCabeceraList;

    public Clientes() {
    }

    public Clientes(Integer codCliente) {
        this.codCliente = codCliente;
    }

    public Integer getCodCliente() {
        return codCliente;
    }

    public void setCodCliente(Integer codCliente) {
        this.codCliente = codCliente;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getTelefono() {
        return telefono;
    }

    public void setTelefono(String telefono) {
        this.telefono = telefono;
    }

    public Float getLimiteCredito() {
        return limiteCredito;
    }

    public void setLimiteCredito(Float limiteCredito) {
        this.limiteCredito = limiteCredito;
    }

    public Integer getSaldoActual() {
        return saldoActual;
    }

    public void setSaldoActual(Integer saldoActual) {
        this.saldoActual = saldoActual;
    }

    @XmlTransient
    public List<VentasCabecera> getVentasCabeceraList() {
        return ventasCabeceraList;
    }

    public void setVentasCabeceraList(List<VentasCabecera> ventasCabeceraList) {
        this.ventasCabeceraList = ventasCabeceraList;
    }

    @XmlTransient
    public List<OrdenesCabecera> getOrdenesCabeceraList() {
        return ordenesCabeceraList;
    }

    public void setOrdenesCabeceraList(List<OrdenesCabecera> ordenesCabeceraList) {
        this.ordenesCabeceraList = ordenesCabeceraList;
    }

    @XmlTransient
    public List<Pagos> getPagosList() {
        return pagosList;
    }

    public void setPagosList(List<Pagos> pagosList) {
        this.pagosList = pagosList;
    }

    @XmlTransient
    public List<PagosDetalle> getPagosDetalleList() {
        return pagosDetalleList;
    }

    public void setPagosDetalleList(List<PagosDetalle> pagosDetalleList) {
        this.pagosDetalleList = pagosDetalleList;
    }

    @XmlTransient
    public List<OrdenesDetalle> getOrdenesDetalleList() {
        return ordenesDetalleList;
    }

    public void setOrdenesDetalleList(List<OrdenesDetalle> ordenesDetalleList) {
        this.ordenesDetalleList = ordenesDetalleList;
    }

    @XmlTransient
    public List<PagosCabecera> getPagosCabeceraList() {
        return pagosCabeceraList;
    }

    public void setPagosCabeceraList(List<PagosCabecera> pagosCabeceraList) {
        this.pagosCabeceraList = pagosCabeceraList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codCliente != null ? codCliente.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Clientes)) {
            return false;
        }
        Clientes other = (Clientes) object;
        if ((this.codCliente == null && other.codCliente != null) || (this.codCliente != null && !this.codCliente.equals(other.codCliente))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Clientes[ codCliente=" + codCliente + " ]";
    }
    
}
